﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Hs.CardUt
{
    public class Tools
    {
        // Token: 0x06000014 RID: 20 RVA: 0x00003334 File Offset: 0x00001534
        public static string GetBytesConvertHexdecimalString(byte[] btData, int startIndex, int dataLength)
        {
            string text = "";
            for (int i = 0; i < dataLength; i++)
            {
                text += btData[startIndex + i].ToString("X2");
            }
            return text;
        }

        // Token: 0x06000015 RID: 21 RVA: 0x0000337C File Offset: 0x0000157C
        public static byte[] GetStringConvertBytes(string str)
        {
            byte[] array = new byte[str.Length / 2];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = Convert.ToByte(str.Substring(i * 2, 2), 16);
            }
            return array;
        }

        // Token: 0x06000016 RID: 22 RVA: 0x000033C8 File Offset: 0x000015C8
        public static string GetAsciiConvertHexdecimal(string str)
        {
            byte[] bytes = Encoding.Default.GetBytes(str);
            StringBuilder stringBuilder = new StringBuilder();
            foreach (byte b in bytes)
            {
                stringBuilder.Append(b.ToString("x"));
            }
            return stringBuilder.ToString();
        }

        // Token: 0x06000017 RID: 23 RVA: 0x0000342C File Offset: 0x0000162C
        public static string GetHexdecimalConvertAscii(string str)
        {
            byte[] array = new byte[str.Length / 2];
            int num = 0;
            for (int i = 0; i < str.Length; i += 2)
            {
                array[num] = Convert.ToByte(str.Substring(i, 2), 16);
                num++;
            }
            return Encoding.Default.GetString(array);
        }

        // Token: 0x06000018 RID: 24 RVA: 0x0000348C File Offset: 0x0000168C
        public static DateTime GetTime(string messageTime)
        {
            string value = string.Concat(new string[]
            {
                messageTime.Substring(0, 4),
                "-",
                messageTime.Substring(4, 2),
                "-",
                messageTime.Substring(6, 2),
                " ",
                messageTime.Substring(8, 2),
                ":",
                messageTime.Substring(10, 2),
                ":",
                messageTime.Substring(12, 2)
            });
            return Convert.ToDateTime(value);
        }
    }
}
